#include <stdio.h>
#include "../constants.hpp"
#include "CommittedNextBatch.hpp"

using namespace BFT::messages;

CommittedNextBatch::CommittedNextBatch(uint32_t _view, boost::shared_ptr<NextBatch> _nb)
{

CommittedNextBatch::CommittedNextBatch(_view, _nb.get()->getSeqNo(), _nb.get()->getHistory(), 
						     _nb.get()->getCommands(), _nb.get()->getNonDeterminism(), _nb.get()->getCPDigest(),
						     _nb.get()->getTakeCP(), _nb.get()->getSendingReplica());
}

CommittedNextBatch::CommittedNextBatch(  uint32_t _view, uint32_t _seq,
					     boost::shared_ptr<HistoryDigest> _history,
					     boost::shared_ptr<CommandBatch> _commands,
					     boost::shared_ptr<NonDeterminism> _nondet,
					     boost::shared_ptr<Digest> _cpDig, bool _cp, uint32_t _sendingReplica)
	: NextBatch::NextBatch(COMMITTED_NEXT_BATCH, _view, _seq, _history, _commands, _nondet, _cpDig, _cp , _sendingReplica)
{}

CommittedNextBatch::CommittedNextBatch(uint32_t _view, uint32_t _seq,
					     boost::shared_ptr<CertificateEntry> _entry,
					     bool _cp, uint32_t _sendingReplica)
	: NextBatch::NextBatch(COMMITTED_NEXT_BATCH, _view, _seq, _entry, _cp, _sendingReplica)
{
//	fprintf(stderr, "++++++++++ %d ++++++++++\n",_sendingReplica);
}
					     
CommittedNextBatch::CommittedNextBatch(boost::shared_ptr<char> _bytes, int _bytes_size)
	: NextBatch::NextBatch(_bytes, _bytes_size)
{
	if (getTag() != COMMITTED_NEXT_BATCH)
	{
		fprintf(stderr,"expected tag %d (committed next batch), real tag %d (? ? ?)\n",COMMITTED_NEXT_BATCH, getTag());
	}	
}

